/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package kernel;

import gestores.iteracao.GestorIteracao;
import gestores.iteracao.LogIteracao;
import gestores.janelas.GestorJanelas;
import java.util.Observable;
import java.util.Observer;

/**
 * Classe Kernel
 *
 * Descrição:
 *
 *
 * @author blaster
 */
public class Kernel implements Observer {

    public GestorJanelas gestorJanelas;
    public GestorIteracao gestorIteracao;
    private static Kernel instance;

    public static Kernel getInstance() {
        if (instance == null) {
            instance = new Kernel();
        }
        return instance;
    }

    private Kernel() {
    }

    public void init() {
        gestorJanelas = new GestorJanelas();
        gestorJanelas.addObserver(this);

        gestorIteracao = new GestorIteracao();
        gestorIteracao.addObserver(this);

        //TODO adicionar demais gestores
    }

    public void stop(){
        gestorJanelas.stop();
        gestorJanelas.deleteObserver(this);

        gestorIteracao.stop();
        gestorIteracao.deleteObserver(this);

    }

    public void update(Observable child, Object arg) {
        if (child instanceof GestorJanelas && arg instanceof String && ((String) arg).equals("sair")) {

        }

        if (child instanceof GestorIteracao && arg instanceof LogIteracao) {
            gestorJanelas.showLogIteracao((LogIteracao) arg);
        }

    }
}
